#include<vector>
#include<stack>
using namespace std;
class Solution {
public:
    bool IsPopOrder(vector<int> pushV,vector<int> popV) {
        stack<int> st;
        int ph=0,pp=0;
        while(ph<pushV.size())
        {
            st.push(pushV[ph++]);
            while(!st.empty()&&st.top()==popV[pp])
            {
                st.pop();
                pp++;
            }
        }
        return st.empty();
    }
};